package utils;

import utils.math_utils.RandStream;

import components.LIFNeuron;

/**
 * 
 * @author zach
 *
 */
public class  LIFRandomizer {

	private RandStream rp;
	
	private double RP;
	
	private RandStream thresh;
	
	private double THRESH;
	
	private RandStream mr;
	
	private double MEMRES;
	
	private RandStream ref;
	
	private double REF;
	
	private RandStream tc;
	
	private double TC;
	
	private RandStream rate;
	
	private double RATE;
	
	private RandStream reset;
	
	private double RESET;
	
	private RandStream bgCurr;
	
	private double BGCURR;
	
	private RandStream mp;
	
	private double MEMPOT;
	
	public LIFRandomizer() {
	}
	
    public void randomizeNeuron(LIFNeuron n) {
    	if (rp != null) {
    		n.setRestPotential(rp.next());
    	} else {
    		n.setRestPotential(RP);
    	}
    	if (thresh != null) {
    		n.setThreshold(thresh.next());
    	} else {
    		n.setThreshold(THRESH);
    	}
    	if (mr != null) {
    		n.setMemResistance(mr.next());
    	} else {
    		n.setMemResistance(MEMRES);
    	}
    	if (ref != null) {
    		n.setRefractory(ref.next());
    	} else {
    		n.setRefractory(REF);
    	}
    	if (tc != null) {
    		n.setTimeConstant(tc.next());
    	} else {
    		n.setTimeConstant(TC);
    	}
    	if (rate != null) {
    		n.setPreferredISI(rate.next());
    	} else if (RATE != 0) {
    		n.setPreferredISI(RATE);
    	} else {
    		n.setHmP(false);
    	}
    	if (reset != null) {
    		n.setReset(reset.next());
    	} else {
    		n.setReset(RESET);
    	}
    	if(bgCurr != null) {
    		n.setBgCurrent(bgCurr.next());
    	} else {
    		n.setBgCurrent(BGCURR);
    	}
    	if(mp != null) {
    		n.setMemPotential(mp.next());
    	} else {
    		n.setMemPotential(MEMPOT);
    	}
    	
    }
    
    public double sampleTc(){
    	return tc.next();
    }

	public RandStream getRp() {
		return rp;
	}


	public void setRp(RandStream rp) {
		this.rp = rp;
	}


	public RandStream getMr() {
		return mr;
	}


	public void setMr(RandStream mr) {
		this.mr = mr;
	}


	public RandStream getTc() {
		return tc;
	}


	public void setTc(RandStream tc) {
		this.tc = tc;
	}


	public RandStream getRate() {
		return rate;
	}


	public void setRate(RandStream rate) {
		this.rate = rate;
	}


	public RandStream getReset() {
		return reset;
	}


	public void setReset(RandStream reset) {
		this.reset = reset;
	}


	public RandStream getBgCurr() {
		return bgCurr;
	}


	public void setBgCurr(RandStream bgCurr) {
		this.bgCurr = bgCurr;
	}


	public RandStream getThresh() {
		return thresh;
	}


	public RandStream getRef() {
		return ref;
	}

	public RandStream getMp() {
		return mp;
	}

	public void setMp(RandStream mp) {
		this.mp = mp;
	}

	public double getRP() {
		return RP;
	}

	public void setRP(double rP) {
		RP = rP;
	}

	public double getTHRESH() {
		return THRESH;
	}

	public void setTHRESH(double tHRESH) {
		THRESH = tHRESH;
	}

	public double getMEMRES() {
		return MEMRES;
	}

	public void setMEMRES(double mEMRES) {
		MEMRES = mEMRES;
	}

	public double getREF() {
		return REF;
	}

	public void setREF(double rEF) {
		REF = rEF;
	}

	public double getTC() {
		return TC;
	}

	public void setTC(double tC) {
		TC = tC;
	}

	public double getRATE() {
		return RATE;
	}

	public void setRATE(double rATE) {
		RATE = rATE;
	}

	public double getRESET() {
		return RESET;
	}

	public void setRESET(double rESET) {
		RESET = rESET;
	}

	public double getBGCURR() {
		return BGCURR;
	}

	public void setBGCURR(double bGCURR) {
		BGCURR = bGCURR;
	}

	public double getMEMPOT() {
		return MEMPOT;
	}

	public void setMEMPOT(double mEMPOT) {
		MEMPOT = mEMPOT;
	}

	public void setThresh(RandStream thresh) {
		this.thresh = thresh;
	}

	public void setRef(RandStream ref) {
		this.ref = ref;
	}

}
